/* * Sun Public License Notice * * The contents of this file are subject to the Sun Public License * Version 1.0 (the "License"). You may not use this file except in * compliance with the License. A copy of the License is available at * http://www.sun.com/ * * The Original Code is Forte for Java, Community Edition. The Initial * Developer of the Original Code is Sun Microsystems, Inc. Portions * Copyright 1997-2000 Sun Microsystems, Inc. All Rights Reserved. */ package org.netbeans.modules.vcs.cmdline.commands; import org.openide.*; import org.netbeans.modules.vcs.util.*; /** * * @author Martin Entlicher * @version */ public class CvsModuleSelectorDialog extends javax.swing.JDialog { private String[] modules = null; private boolean validSelection = false; //private volatile InformationDialog waitDlg = null; static final long serialVersionUID = 1987612235843595460L; /** Creates new form CvsModuleSelectorDialog */ public CvsModuleSelectorDialog(java.awt.Frame parent,boolean modal) { super (parent, modal); initComponents (); setTitle(org.openide.util.NbBundle.getBundle(CvsModuleSelectorDialog.class).getString("CvsModuleSelectorDialog.title")); pack (); } /** This method is called from within the constructor to * initialize the form. * WARNING: Do NOT modify this code. The content of this method is * always regenerated by the FormEditor. */ private void initComponents () {//GEN-BEGIN:initComponents statusLabel = new javax.swing.JLabel (); listScrollPane = new javax.swing.JScrollPane (); moduleList = new javax.swing.JList (); okButton = new javax.swing.JButton (); cancelButton = new javax.swing.JButton (); getContentPane ().setLayout (new java.awt.GridBagLayout ()); java.awt.GridBagConstraints gridBagConstraints1; addWindowListener (new java.awt.event.WindowAdapter () { public void windowClosing (java.awt.event.WindowEvent evt) { closeDialog (evt); } } ); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridwidth = 2; gridBagConstraints1.fill = java.awt.GridBagConstraints.HORIZONTAL; gridBagConstraints1.insets = new java.awt.Insets (8, 8, 0, 8); gridBagConstraints1.anchor = java.awt.GridBagConstraints.WEST; gridBagConstraints1.weightx = 1.0; getContentPane ().add (statusLabel, gridBagConstraints1); listScrollPane.setViewportView (moduleList); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridy = 1; gridBagConstraints1.gridwidth = 2; gridBagConstraints1.fill = java.awt.GridBagConstraints.BOTH; gridBagConstraints1.insets = new java.awt.Insets (8, 8, 8, 8); gridBagConstraints1.weightx = 1.0; gridBagConstraints1.weighty = 1.0; getContentPane ().add (listScrollPane, gridBagConstraints1); okButton.setText (org.openide.util.NbBundle.getBundle(CvsModuleSelectorDialog.class).getString("CvsModuleSelectorDialog.okButton.text")); okButton.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { okButtonActionPerformed (evt); } } ); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridy = 2; gridBagConstraints1.insets = new java.awt.Insets (0, 8, 8, 0); gridBagConstraints1.weightx = 1.0; getContentPane ().add (okButton, gridBagConstraints1); cancelButton.setText (org.openide.util.NbBundle.getBundle(CvsModuleSelectorDialog.class).getString("CvsModuleSelectorDialog.cancelButton.text")); cancelButton.addActionListener (new java.awt.event.ActionListener () { public void actionPerformed (java.awt.event.ActionEvent evt) { cancelButtonActionPerformed (evt); } } ); gridBagConstraints1 = new java.awt.GridBagConstraints (); gridBagConstraints1.gridy = 2; gridBagConstraints1.insets = new java.awt.Insets (0, 0, 8, 8); gridBagConstraints1.weightx = 1.0; getContentPane ().add (cancelButton, gridBagConstraints1); }//GEN-END:initComponents private void cancelButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cancelButtonActionPerformed // Add your handling code here: validSelection = false; closeDialog(null); }//GEN-LAST:event_cancelButtonActionPerformed private void okButtonActionPerformed (java.awt.event.ActionEvent evt) {//GEN-FIRST:event_okButtonActionPerformed // Add your handling code here: validSelection = true; closeDialog(null); }//GEN-LAST:event_okButtonActionPerformed /** Closes the dialog */ private void closeDialog(java.awt.event.WindowEvent evt) {//GEN-FIRST:event_closeDialog setVisible (false); dispose (); }//GEN-LAST:event_closeDialog public boolean showDialog() { show(); return validSelection; } public void waitingForModules() { statusLabel.setText(org.openide.util.NbBundle.getBundle(CvsModuleSelectorDialog.class).getString("CvsModuleSelectorDialog.waitingForModules")); /* if (waitDlg == null) { javax.swing.SwingUtilities.invokeLater(new Runnable () { public void run () { waitDlg = new InformationDialog(new java.awt.Frame(), true, "Please wait, modules are loading ..."); MiscStuff.centerWindow(waitDlg); waitDlg.show(); } }); } */ } public void setModules(String[] modules) { this.modules = modules; //if (waitDlg != null) waitDlg.setVisible(false); if (modules == null || modules.length == 0) { javax.swing.SwingUtilities.invokeLater(new Runnable() { public void run() { NotifyDescriptor nd = new NotifyDescriptor.Message (org.openide.util.NbBundle.getBundle(CvsModuleSelectorDialog.class).getString("CvsModuleSelectorDialog.noModules")); TopManager.getDefault ().notify (nd); } }); closeDialog(null); } else { statusLabel.setText(org.openide.util.NbBundle.getBundle(CvsModuleSelectorDialog.class).getString("CvsModuleSelectorDialog.modulesLoaded")); moduleList.setListData(modules); } } public String getSelection() { if (modules == null) return null; if (validSelection) return (String) moduleList.getSelectedValue(); else return null; } // Variables declaration - do not modify//GEN-BEGIN:variables private javax.swing.JLabel statusLabel; private javax.swing.JScrollPane listScrollPane; private javax.swing.JList moduleList; private javax.swing.JButton okButton; private javax.swing.JButton cancelButton; // End of variables declaration//GEN-END:variables }